import './font.css'
import myAlert from './01.myAlert.vue'
import myLink from './02.myLink.vue'
import myButton from './03.myButton.vue'
import myInput from './04.myInput.vue'
import mySwitch from './05.mySwitch.vue'
import myFormItem from './06.myFormItem.vue'
import myForm from './07.myForm.vue'
import myDialog from './08.myDialog.vue'
import myMessage from './09.myMessage.vue'
export default function (Vue) {
  Vue.component(myAlert.name, myAlert)
  Vue.component(myLink.name, myLink)
  Vue.component(myButton.name, myButton)
  Vue.component(myInput.name, myInput)
  Vue.component(mySwitch.name, mySwitch)
  Vue.component(myFormItem.name, myFormItem)
  Vue.component(myForm.name, myForm)
  Vue.component(myDialog.name, myDialog)
  Vue.component(myMessage.name, myMessage)

  // 暴露一个方法
  Vue.prototype.$message = function (option) {
    console.log(option)
    // 创建构造函数
    const MyMessage = Vue.extend(myMessage)
    // 实例化组件
    const messageObj = new MyMessage()
    // 赋值
    messageObj.title = option.title
    messageObj.duration = option.duration
    // mount
    messageObj.$mount()
    // 获取 el
    // 添加到body上
    document.body.appendChild(messageObj.$el)
  }
}
